package com.keymozy.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class GetTimeUtil {
    public static String getTimeOfSeconds(){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    public static String getTimeOfSeconds(String format){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
    public static long subTime(String t1,String t2,String format){
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        try {
            Date d1 = sdf.parse(t1);
            Date d2 = sdf.parse(t2);
            return d1.getTime() - d2.getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0;
    }
}
